package com.lxw.report.meta.query;

import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReportGetRequest {
    /**
     * 报表Id
     */
    private String id;
    /**
     * 查询参数的map
     */
    private Map<String, String[]> map;
    /**
     * 是否分页
     */
    private Boolean pagination;
    /**
     * 页码
     */
    private int pageNumber = 1;
    /**
     * 页尺寸
     */
    private int pageSize = 10;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Map getMap() {
        return map;
    }

    public void setMap(Map<String, String[]>  map) {
        this.map = map;
    }

    public void setMap(String map) {
        Map<Object, Object> mapObject= JSONObject.parseObject(map,Map.class);
        Map<String, String[]> mapT=new HashMap<String, String[]>();
        for (Object key : mapObject.keySet()){
            Object objectValue=mapObject.get(key);
            List<String> valueList=JSONObject.parseArray(objectValue.toString(),String.class);
            String[] valueT = new String[valueList.size()];
            valueList.toArray(valueT);
            mapT.put(key.toString(),valueT);

        }
        System.out.println("========>"+JSONObject.toJSONString(mapT));
        this.map = mapT;
    }

    public Boolean getPagination() {
        return pagination;
    }

    public void setPagination(Boolean pagination) {
        this.pagination = pagination;
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getBeginItemIndex() {
        return (this.getPageNumber() - 1) * this.getPageSize();
    }

    public int getEndItemIndex() {
        return this.getPageNumber() * this.getPageSize();
    }
}
